package com.tancire.web.controller.app;

import com.tancire.common.core.domain.AjaxResult;
import com.tancire.net.domain.AuthDetail;
import com.tancire.net.service.IAuthInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 资源授权码获取
 *
 */
@RestController
@RequestMapping("/net/app/auth")
public class SourceSecretController {

    @Resource
    private IAuthInfoService authInfoService;

    /**
     * 获取会员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:user:union')")
    @PostMapping(value = "/retrieval")
    public AjaxResult authByCode(@RequestBody AuthDetail authDetail) {
        AuthDetail res = authInfoService.authByCode(authDetail, true);
        return AjaxResult.success("success", res);
    }

    /**
     * 获取认证应用（资源）信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:user:union')")
    @GetMapping(value = "/info/{code}")
    public AjaxResult getInfo(@PathVariable("code") String code) {
        return AjaxResult.success(authInfoService.selectAuthInfoByCode(code));
    }
}
